<style scoped>

</style>
<template>
    <div style="text-align:center">

        <div>登录</div>
        <div>
            <span>用户名：</span><input type="text" v-model="username">
        </div>
        <div>
            <span>&nbsp;&nbsp;&nbsp;&nbsp;密码：</span><input type="text" v-model="password">
        </div>
        <button @click="clickLogin">登录</button>
    </div>
</template>
<script>
    export default {
        data () {
            return {
                username: '',
                password: ''
            }
        },
        methods: {
            test () {
                if (this.username != '' && this.password != '') {
                    return true;
                } else {
                    alert('用户名和密码不能为空');
                    return false;
                }
            },
            clickLogin () {
                if (this.test()) {
                    localStorage.chinaUsername = this.username;
                    localStorage.chinapassword = this.password;
                    location.href = '/#/index';
                }
            }
        }
    }
</script>

